package
{
	import com.societyGames.codeExercise.IServiceProvider;
	import com.societyGames.precedenceExercises.PrecedenceCodeExercise;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class Precedence extends PrecedenceCodeExercise
	{
		private var _isSuccessful:Boolean = false;
		private var _isFirstOutput:Boolean = true;
		
		public function Precedence()
		{
			var func:Function;
			func = getX;
			func = getY;
			func = getZ;
		}
		
		public override function queueOutput(... arguments):void
		{	
			if (this._isFirstOutput && arguments.length == 1 && arguments[0] == this._precedenceSimulation.evaluate())
			{
				this._isSuccessful = true;
			}
			this._isFirstOutput = false;
			super.queueOutput.apply(this, arguments);
		}
		
		//ICodeExercise-->
		protected override function evaluateWithExceptionsHandled():void
		{
			if (this._isSuccessful)
			{
				queueReportSuccess();
			}
			else
			{
				queueReportFailure();
			}
		}
		//<--ICodeExercise
	}
}